import Cookies from 'js-cookie'
class Keys {
	static sidebarStatusKey = 'jm-sidebarStatusKey'
	static sizeKey = 'jm-sizeKey'
	static tokenKey = 'token'
	static redirectUrl = 'jm-redirectUrl'
  static userId = 'user_id'
}
export const getSidebarStatus = () => Cookies.get(Keys.sidebarStatusKey)
export const setSidebarStatus = sidebarStatus => Cookies.set(Keys.sidebarStatusKey, sidebarStatus)

export const getSize = () => Cookies.get(Keys.sizeKey)
export const setSize = size => Cookies.set(Keys.sizeKey, size)

// TODO cookie 的有效期时间过期，浏览器会自动删除
export const getToken = () => Cookies.get(Keys.tokenKey)
export const setToken = token => Cookies.set(Keys.tokenKey, token)
export const removeToken = () => Cookies.remove(Keys.tokenKey)

export const getRedirectUrl = () => Cookies.get(Keys.redirectUrl)
export const setRedirectUrl = redirectUrl => Cookies.set(Keys.redirectUrl, redirectUrl)
export const removeRedirectUrl = () => Cookies.remove(Keys.redirectUrl)

export const getUserId = () => Cookies.get(Keys.userId)
export const setUserId = userId => Cookies.set(Keys.userId, userId)
export const removeUserId = () => Cookies.remove(Keys.userId)
